﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SageKing.Core.Contracts;
public class MessageModelForm:ICloneable
{
    public List<KeyValueClass<string, string>> AttStrLst { get; set; }
    public List<KeyValueClass<string, sbyte>> AttsbyteLst { get; set; }
    public List<KeyValueClass<string, byte>> AttbyteLst { get; set; }
    public List<KeyValueClass<string, short>> AttshortLst { get; set; }
    public List<KeyValueClass<string, ushort>> AttushortLst { get; set; }
    public List<KeyValueClass<string, int>> AttintLst { get; set; }
    public List<KeyValueClass<string, uint>> AttuintLst { get; set; }
    public List<KeyValueClass<string, long>> AttlongLst { get; set; }
    public List<KeyValueClass<string, ulong>> AttulongLst { get; set; }
    public List<KeyValueClass<string, float>> AttfloatLst { get; set; }
    public List<KeyValueClass<string, double>> AttdoubleLst { get; set; }

    public object Clone()
    {
        return this.MemberwiseClone();
    }

    /// <summary>
    /// 初始化到ISageKingMessage
    /// </summary>
    /// <param name="sageKingMessage"></param>
    public void InitToSageKingMessage(ISageKingMessage sageKingMessage)
    {
        sageKingMessage.ClearAll();
        #region init model

        if (AttStrLst.HasItem())
        {
            foreach (var item in AttStrLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<string>(item.Value));
            }
        }
        if (AttsbyteLst.HasItem())
        {
            foreach (var item in AttsbyteLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<sbyte>(item.Value));
            }
        }
        if (AttbyteLst.HasItem())
        {
            foreach (var item in AttbyteLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<byte>(item.Value));
            }
        }
        if (AttintLst.HasItem())
        {
            foreach (var item in AttintLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<int>(item.Value));
            }
        }
        if (AttuintLst.HasItem())
        {
            foreach (var item in AttuintLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<uint>(item.Value));
            }
        }
        if (AttushortLst.HasItem())
        {
            foreach (var item in AttushortLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<ushort>(item.Value));
            }
        }
        if (AttshortLst.HasItem())
        {
            foreach (var item in AttshortLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<short>(item.Value));
            }
        }
        if (AttlongLst.HasItem())
        {
            foreach (var item in AttlongLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<long>(item.Value));
            }
        }
        if (AttulongLst.HasItem())
        {
            foreach (var item in AttulongLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<ulong>(item.Value));
            }
        }
        if (AttfloatLst.HasItem())
        {
            foreach (var item in AttfloatLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<float>(item.Value));
            }
        }
        if (AttdoubleLst.HasItem())
        {
            foreach (var item in AttdoubleLst)
            {
                sageKingMessage.AddOrUpdate(item.Key, new DataStreamTypValue<double>(item.Value));
            }
        }
        #endregion

    }

}
